package com.zb.ssm.service.impl;


import com.zb.ssm.dao.EmpDao;
import com.zb.ssm.entity.EmpEntity;
import com.zb.ssm.entity.Result;
import com.zb.ssm.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmpServiceImpl implements EmpService {

    @Autowired
    private EmpDao empDao;

    @Override
    public Result<?> insert(EmpEntity empEntity) {
        int insert = empDao.insert(empEntity);
        return insert == 1?Result.success():Result.fail();
    }

    @Override
    public Result<?> deleteById(int id) {
        int res = empDao.deleteById(id);
        return res >= 1 ? Result.success(): Result.fail();
    }

    @Override
    public Result<?> updateById(EmpEntity empEntity) {
        int res = empDao.updateById(empEntity);
        return res >= 1 ? Result.success(): Result.fail();
    }

    @Override
    public Result<List<EmpEntity>> select() {
        List<EmpEntity> list = empDao.select();
        return Result.success(list);
    }

    @Override
    public Result<EmpEntity> selectById(int id) {
        EmpEntity empEntity = empDao.selectById(id);
        return Result.success(empEntity);
    }
}
